/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Lixo;

import bancodedados3d.*;
import com.sun.j3d.utils.behaviors.mouse.MouseRotate;
import com.sun.j3d.utils.behaviors.mouse.MouseWheelZoom;
import javax.media.j3d.BoundingSphere;
import javax.media.j3d.BranchGroup;
import javax.media.j3d.DirectionalLight;
import javax.media.j3d.Transform3D;
import javax.media.j3d.TransformGroup;
import javax.vecmath.Vector3f;

/**
 *
 * @author fosa
 */
public class tabela3D extends BranchGroup {

    TransformGroup root_group = new TransformGroup();

    public tabela3D(String[][] str) {
        root_group.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); // allow the mouse behavior to rotate the scene
        root_group.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
        this.addChild(root_group);  // this is the local origin  - everyone hangs off this - moving this move every one

//      parte
        Transform3D tabela = new Transform3D();
        tabela.setScale(0.2);       // shrink the sphere so our view point is not inside it
        TransformGroup tabelaGrupo = new TransformGroup(tabela);
        root_group.addChild(tabelaGrupo);


        float flx = -0.2f;
        float fly = 0.2f;


        for (int j = 0; j < str.length; j++) {
            for (int i = 0; i < str[j].length; i++) {
                root_group.addChild(new Texto3D(flx, fly, 0.0f, str[j][i]));
                flx += 0.2f;
            }
            fly -= 0.2f;
        }
//        root_group.addChild(new Texto3D(0.2f, 0.2f, 0.0f, "Teste"));

        BoundingSphere area = new BoundingSphere(); // the render will only light objects inside this volume
        area.setRadius(1000.0);

        // add a light so we can see the sphere
        DirectionalLight luz = new DirectionalLight();
        luz.setInfluencingBounds(area);
        luz.setDirection(new Vector3f(.7f, -.7f, -.7f));  // point the light right, down, into the screen
        this.addChild(luz);


//        3parte
        MouseWheelZoom zoom = new MouseWheelZoom(root_group);
        zoom.setSchedulingBounds(new BoundingSphere());
        this.addChild(zoom);

        MouseRotate mouseRotate = new MouseRotate(root_group);  // add the mouse behavior
        mouseRotate.setSchedulingBounds(new BoundingSphere());
        this.addChild(mouseRotate);
//        return objRoot;

    }
}
